#ifndef WOLF_CONSOLE_TEST_HPP
#define WOLF_CONSOLE_TEST_HPP

#include "StdTest.hpp"
#include "console.hpp"

namespace wolf
{
    class ConsoleTest : public StdTest
    {
    public:
        ConsoleTest(): StdTest( "Console" ) {}
        ~ConsoleTest() {}

        bool run( Engine &engine )
        {
            SDL_EnableUNICODE( true );
            SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
            StdFont font;
            Console console( 480 / 8, 640 / 8, &font );
            engine.addManager( console );

            console.write( "Console is working!\nReally!\n" );
            console.setCursorColumn( 5 );
            console.setCursorLine( 7 );
            console.write( "And it is moving!" );
            console.setListening( true );
            console.setColor( 0x00FFAAFF );
            console.setInput( '\0' );
            console.setShowing(true);
            while( engine.isRunning() )
            {
                char input = console.getInput();
                if( input != '\0' )
                {
                    console.setInput( '\0' );
                    if(input == '\b') console.clear();
                    else console.write( input );
                }
                engine.doFrame();
            }
            return true;
        }
    };

}

#endif // WOLF_CONSOLE_TEST_HPP

